import { makeAutoObservable } from "mobx";
import { getCookie, getLocationSearch } from '../utils';

export default class SdkStore {
    mockConfig = {
      appId: '2XC7AKWDVNWOFO2C',
      userId: 't2',
      accessKey:'JMXS2ESG715PN5KF',
      tntInstId: 'DEMOISVT',
      bizType: 'imdemo',
      heartBeatCheckTime: 30,
      useRtc: true,
      useLocalDbEmoji: true,
      rtcPubVideoProfile: {
        resolution: '1080p'
      },
      resource: {},
      // usePreServer: true, //是否使用implus预发环境服务
      ...getLocationSearch(),
    }
    currentMeetingInfo = null;
    inChatCid = null;
    newMessageTopBarProps = { visible: false };
    converList= [];
    currentMessageList = [];
    newMessageData = [];
    showLogin=true;
    sdkInitOk=false;
    sdk = null;
    emojiList = [];
    isHideSomeFunctions = false;

    constructor() {
      const loginInfo = getCookie();
      if(loginInfo.userId) {
        this.mockConfig = {...this.mockConfig, ...loginInfo };
        this.showLogin = false;
      }
      makeAutoObservable(this)
    }

    setVal(key, value) {
      key && (this[key] = value);
    }

    updateConverList(list) {
      if(list && list instanceof Array) {
        this.converList = list;
      }
    }

    updateCurrentMessageList(list) {
      if(list && list instanceof Array) {
        this.currentMessageList = [...list];
      }
    }

    setNewMessageData(msg) {
      if(msg && msg instanceof Object) {
        this.newMessageData = msg;
      }
    }

    setNewMessageTopBarProps(Props) {
      this.newMessageTopBarProps = {...Props};
    }

    setInChatCid(cid) {
      this.inChatCid = cid
    }

    setCurrentMeetingInfo(info) {
      this.currentMeetingInfo = {...info};
    }
}